package designpattern.composite;

import java.util.ArrayList;
import java.util.List;

public class Flock implements Animal {
    List<Animal> animals =new ArrayList<>();

    @Override
    public void eat() {
        for(Animal animal : animals){
            animal.eat();
        }
    }

    @Override
    public void add(Animal animal){
        animals.add(animal);
    }

}
